<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  brand.php
//  www.6block.com
//  
//  Created by Will_Lee on 2011-05-19.
//  Copyright 2011 lishuzu. All rights reserved.
// 


class Brand extends CI_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('Brand_model');
 		$this->load->model('common/security_model');
		$this->userinfo = $this->session->userdata('userinfo');
		$this->brands = $this->config->item('brand');
		// 分类缓存
		$this->category = $this->config->item('category');
	}
	function index(){
		$data = $this->Brand_model->get_brand_data();
		$data['userinfo'] = $this->userinfo;
		//分类信息
		$data['category'] = $this->category;
		$this->load->template('brand_tpl',$data);
	}
	
	function orderBrand(){
		$email = $this->input->post('email') ? $this->input->post('email', true): '';
		$brandids = $this->input->post('brand_selected') ? $this->input->post('brand_selected', true): '';

		if($this->security_model->isLogin() === FALSE){
          showmessage('请登录', 'login/index', 3);
		}
		
		if ($email && !empty($brandids)) {
			$data = array(
				'email' => $email,
				'brandids' => $brandids
				);
			$result = $this->Brand_model->orderbrand($data);
			if ($result) {
				showmessage('操作成功', 'brand', 2);
			}else{
				showmessage('操作失败', 'brand', 2);
			}
		}else{
			showmessage('请填写邮箱地址,选择相应品牌', 'brand', 2);
		}
	}
}